package tech.aistar.corejava.day09.Stringextends;

/**
 * Created by 豆梦寒 on 2019/7/26.
 */
public class StringCompareDemo {
    public static void main(String[] args) {
        //问题 创建了几个问题？
        //创建了1个或者3个问题
        //前提 串池中是否存在 "abc"
        String s2 = "abc";//若存在 就是1个 否则就是两个
        String s1 = new String("abc");

        String s3 = "a" + "b" + "c";

        System.out.println(s2 == s1);

        //final修饰的字符串，肯定在编译期间，jvm在编译期间，就会把这句话优化成"a"+"b"
        final String x1 = "a";
        String x2 = x1 + "b";

        String x4 = "a"+"b";

        String x3 = "ab";
        System.out.println(x3==x2);
        System.out.println(x3==x4);

    }
}
